package com.penjin.android.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.penjin.android.R;
import com.penjin.android.domain.KaoqinLeaveData;
import com.penjin.android.domain.KaoqinPersonData;
import com.penjin.android.domain.KaoqinTiaoxiuData;
import com.penjin.android.domain.PenjinDepartment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fengjw on 2016/4/9.
 */
public class ListAdapterKaoqinTiaoxiu extends BaseAdapter {
    //activity nosign
    Context mContext;

    //activity tiaoxiu
    List<KaoqinLeaveData> kaoqinLeaveDataList = new ArrayList<>();
    List<KaoqinTiaoxiuData> kaoqinTiaoxiuDataList = new ArrayList<>();
    private String name1,name2;
    int [] arr = { 1 , 2};

    public ListAdapterKaoqinTiaoxiu(Context context ){
        this.mContext = context;
    }

    public void setData(String name1, String name2, List<KaoqinLeaveData> kaoqinLeaveDataList, List<KaoqinTiaoxiuData> kaoqinTiaoxiuDataList){
        this.name1 = name1 ;
        this.name2 = name2 ;
        this.kaoqinLeaveDataList = kaoqinLeaveDataList ;
        this.kaoqinTiaoxiuDataList = kaoqinTiaoxiuDataList ;

    }

    @Override
    public int getCount() {
        return arr.length;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return arr[position];
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        ListHolder holder=null;

        if(null == holder){
            holder=new ListHolder();

            convertView= LayoutInflater.from(mContext).inflate(R.layout.listview_kaoqinnosign_item, null);

            holder.name=(TextView) convertView.findViewById(R.id.textView1);
            holder.gridview=(InnerGridView) convertView.findViewById(R.id.gridview);
            holder.head_item=(LinearLayout) convertView.findViewById(R.id.head_item);

            convertView.setTag(holder);
        }else{
            holder=(ListHolder) convertView.getTag();
        }
        GridViewKaoqinLeaveAdapter gridViewAdapter1;
        GridViewKaoqinTiaoxiuAdapter gridViewAdapter2;
        if (0 == position) {
            holder.name.setText(name1);
            gridViewAdapter1 = new GridViewKaoqinLeaveAdapter(mContext , kaoqinLeaveDataList);
            holder.gridview.setAdapter(gridViewAdapter1);
        }else if(1 == position){
            holder.name.setText(name2);
            //Log.d("fengjw","Adapter name2 : "+name2);
            gridViewAdapter2 = new GridViewKaoqinTiaoxiuAdapter(mContext , kaoqinTiaoxiuDataList);
            //Log.d("fengjw","kaoqinTiaoxiu : "+kaoqinTiaoxiuDataList.get(0).getName());
           // Log.d("fengjw","kaoqinTiaoxiu : "+kaoqinTiaoxiuDataList.get(1).getName());
            holder.gridview.setAdapter(gridViewAdapter2);
        }

        return convertView;
    }

    public static class ListHolder{
        TextView name;
        InnerGridView gridview;
        LinearLayout head_item;
    }
}
